package com.zjw.zy.coreui.fragment.holder

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.zjw.zy.R
import com.zjw.zy.bean.DailyWeather
import com.zjw.zy.base.BaseViewHolder
import com.zjw.zy.utils.ResourcesUtils
import com.zjw.zy.utils.TimeUtils
import com.zjw.zy.utils.WeatherUtils

/**
 * @author     ：zhong.jw
 * @date       ：Created in 2022/9/28 11:52
 * @description：15日天气
 */
class Weather15Holder(itemView: View) : BaseViewHolder<DailyWeather>(itemView) {

    private val mWeatherDataText: TextView by lazy { findViewById(R.id.day_weather_current_date_text) }
    private val mWeatherStateText: TextView by lazy { findViewById(R.id.day_weather_state_text) }
    private val mWeatherTempText: TextView by lazy { findViewById(R.id.day_weather_state_temp_text) }
    private val mWeatherStateIcon: ImageView by lazy { findViewById(R.id.day_weather_state_icon) }
    private val mWeatherRainPercentText: TextView by lazy { findViewById(R.id.day_weather_rain_percent_text) }

    override fun onBindData(data: DailyWeather?) {
        data?.let {
            mWeatherDataText.text = TimeUtils.formatDate(it.date)
            mWeatherStateText.text = it.textDay
            mWeatherTempText.text = ResourcesUtils.getString(
                R.string.weather_temp_text,
                it.low,
                it.high
            )
            mWeatherStateIcon.setImageDrawable(WeatherUtils.getWeatherIcon(it))
            mWeatherRainPercentText.text =
                ResourcesUtils.getString(R.string.weather_rain_percent_text, "${it.pop}%")
        }
    }

    override fun onBindListener() {
    }

}